package com.rickpan.dto.siliconflow;

import com.fasterxml.jackson.annotation.JsonInclude;
import java.util.List;

/**
 * 硅基流动AI消息DTO
 * 支持文本和图片多模态内容
 */
@JsonInclude(JsonInclude.Include.NON_NULL)
public class SiliconFlowMessage {

    private String role;
    private Object content; // 可以是String或List<ContentItem>

    // 构造函数
    public SiliconFlowMessage() {}

    public SiliconFlowMessage(String role, String content) {
        this.role = role;
        this.content = content;
    }

    public SiliconFlowMessage(String role, List<ContentItem> content) {
        this.role = role;
        this.content = content;
    }

    // Getter 和 Setter 方法
    public String getRole() {
        return role;
    }

    public void setRole(String role) {
        this.role = role;
    }

    public Object getContent() {
        return content;
    }

    public void setContent(Object content) {
        this.content = content;
    }

    // 便利方法
    public void setContent(String content) {
        this.content = content;
    }

    public void setContent(List<ContentItem> content) {
        this.content = content;
    }

    /**
     * 内容项类，支持文本和图片
     */
    @JsonInclude(JsonInclude.Include.NON_NULL)
    public static class ContentItem {
        private String type; // "text" 或 "image_url"
        private String text; // 当type为text时使用
        private ImageUrl image_url; // 当type为image_url时使用

        public ContentItem() {}

        public ContentItem(String type, String text) {
            this.type = type;
            this.text = text;
        }

        public ContentItem(String type, ImageUrl imageUrl) {
            this.type = type;
            this.image_url = imageUrl;
        }

        // 静态工厂方法
        public static ContentItem text(String text) {
            return new ContentItem("text", text);
        }

        public static ContentItem imageUrl(String url) {
            return new ContentItem("image_url", new ImageUrl(url));
        }

        // Getter 和 Setter
        public String getType() { return type; }
        public void setType(String type) { this.type = type; }

        public String getText() { return text; }
        public void setText(String text) { this.text = text; }

        public ImageUrl getImage_url() { return image_url; }
        public void setImage_url(ImageUrl image_url) { this.image_url = image_url; }
    }

    /**
     * 图片URL类
     */
    @JsonInclude(JsonInclude.Include.NON_NULL)
    public static class ImageUrl {
        private String url;

        public ImageUrl() {}

        public ImageUrl(String url) {
            this.url = url;
        }

        public String getUrl() { return url; }
        public void setUrl(String url) { this.url = url; }
    }

    @Override
    public String toString() {
        return "SiliconFlowMessage{" +
                "role='" + role + '\'' +
                ", content='" + content + '\'' +
                '}';
    }
}
